import 'package:flutter/material.dart';

import '../community/community_page.dart';
import '../game/game_page.dart';
import '../home/home_page.dart';
import '../setting/setting_page.dart';


class MyScaffold extends StatefulWidget {
  const MyScaffold({Key? key}) : super(key: key);

  @override
  State<MyScaffold> createState() => _MyScaffoldState();
}

class _MyScaffoldState extends State<MyScaffold> {

  int currentIndex = 0;
  var list = [const HomePage(), const CommunityPage(), const GamePage(), const SettingPage()];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(
          "题海APP",
        ),
        actions: const [
          Icon(Icons.notifications),
        ],
      ),
      body: list[currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        selectedItemColor: Colors.blueAccent,
        currentIndex: currentIndex,
        type: BottomNavigationBarType.fixed,
        items: const [
          BottomNavigationBarItem(
              icon: Icon(Icons.account_balance_sharp), label: "首页"),
          BottomNavigationBarItem(
              icon: Icon(Icons.home_outlined), label: "社区"),
          BottomNavigationBarItem(
              icon: Icon(Icons.games_outlined), label: "乐园"),
          BottomNavigationBarItem(
              icon: Icon(Icons.person), label: "我的"),
        ],
        onTap: (index){
          setState(() {
            currentIndex = index;
          });
        },
      ),
    );
  }
}

